package util.chessworld;

import generator.Piece;
import util.IConstant;

public class Collision implements IConstant {

    private final Avatar Av;

    public Collision(Avatar A) {
        this.Av = A;
    }

    public boolean testObstacle() {
        if (outOfDomain()) {
            return true;
        }
        Piece[][] pieces = Av.getDomaine().getBoard();
        Piece p;
        if (((p = pieces[Av.X()][Av.Y()]) != null)) {

            if (p.color() == Av.trait()) {
                return true;
            }
        }
        return false;

    }

    private boolean outOfDomain() {
        return (Av.X() < minX) | (Av.X() > maxX) | (Av.Y() < minY) | (Av.Y() > maxY);

    }
}
